package com.movitech.mobile.cz.base.supplier.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.supplier.entity.SSupplierRelateParentCmpy;
import com.movitech.mobile.cz.base.supplier.service.SSupplierRelateParentCmpyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
 * <p>
 * SSupplierRelateParentCmpy 前端控制器
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-02-28
 */
@RestController
@RequestMapping("/v1/sSupplierRelateParentCmpy")
@Api(value = "供方基本情况--关联母公司信息基础操作接口", description = "供方基本情况--关联母公司信息基础操作接口")
public class SSupplierRelateParentCmpyController {
    @Autowired
    @Qualifier("sSupplierRelateParentCmpyService")
    private SSupplierRelateParentCmpyService sSupplierRelateParentCmpyService;

    @GetMapping("/allList")
    @ApiOperation(
            value = "获取所有供方基本情况--关联母公司信息接口",
            notes = "获取所有供方基本情况--关联母公司信息接口",
            response = SSupplierRelateParentCmpy.class
    )
    public RestReturnResult list() {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SSupplierRelateParentCmpy> page = sSupplierRelateParentCmpyService.selectPage(new Page<SSupplierRelateParentCmpy>());
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @PostMapping("/searchList/{pageNumber}")
    @ApiOperation(
            value = "供方基本情况--关联母公司信息列表查询接口",
            notes = "供方基本情况--关联母公司信息列表查询接口",
            response = SSupplierRelateParentCmpy.class
    )
    public RestReturnResult searchList(@RequestBody SSupplierRelateParentCmpy sSupplierRelateParentCmpy,
                @ApiParam(value = "分页页数")@PathVariable Integer pageNumber) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SSupplierRelateParentCmpy> page = new Page<>();
        page.setCurrent(pageNumber);
        EntityWrapper wrapper = new EntityWrapper<>();
        wrapper.setEntity(sSupplierRelateParentCmpy);
        page = sSupplierRelateParentCmpyService.selectPage(page,wrapper);
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @GetMapping("/getSSupplierRelateParentCmpy/{id}")
    @ApiOperation(
            value = "供方基本情况--关联母公司信息对象ID获取接口",
            notes = "供方基本情况--关联母公司信息对对象ID获取接口",
            response = SSupplierRelateParentCmpy.class
    )
    public RestReturnResult addSSupplierRelateParentCmpy(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        SSupplierRelateParentCmpy sSupplierRelateParentCmpy = sSupplierRelateParentCmpyService.selectById(id);
        restReturnResult.setData(sSupplierRelateParentCmpy);
        return restReturnResult;
    }

    @PostMapping("/add")
    @ApiOperation(
            value = "供方基本情况--关联母公司信息添加接口",
            notes = "供方基本情况--关联母公司信息添加接口",
            response = SSupplierRelateParentCmpy.class
    )
    public RestReturnResult add(@RequestBody SSupplierRelateParentCmpy sSupplierRelateParentCmpy) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sSupplierRelateParentCmpyService.insert(sSupplierRelateParentCmpy);
        restReturnResult.setData(sSupplierRelateParentCmpy);
        return restReturnResult;
    }

    @PutMapping("/update")
    @ApiOperation(
            value = "供方基本情况--关联母公司信息更新接口",
            notes = "供方基本情况--关联母公司信息更新接口",
            response = SSupplierRelateParentCmpy.class
    )
    public RestReturnResult update(@RequestBody SSupplierRelateParentCmpy sSupplierRelateParentCmpy) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sSupplierRelateParentCmpyService.updateById(sSupplierRelateParentCmpy);
        restReturnResult.setData(sSupplierRelateParentCmpy);
        return restReturnResult;
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(
            value = "供方基本情况--关联母公司信息通过ID删除接口",
            notes = "供方基本情况--关联母公司信息通过ID删除接口",
            response = SSupplierRelateParentCmpy.class
    )
    public RestReturnResult update(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sSupplierRelateParentCmpyService.deleteById(id);
        return restReturnResult;
    }


}

